package com.qipay.admin.holiday.service;

import com.qipay.holiday.service.HolidayService;
import io.jsonwebtoken.lang.Assert;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * Creator: Yao
 * Date:    2017/12/13
 * For:
 * Other:
 */
@Service
public class HolidayLogicService {

    @Autowired
    HolidayService holidayService;

    private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");


    public HSSFWorkbook export(String year) throws IOException {

        return holidayService.export(year);
    }

    public void upload(String filePath) throws IOException {

        holidayService.upload(filePath);
    }

    public Boolean check(String day) throws ParseException {

        // check
        Assert.isTrue(StringUtils.isNotBlank(day), "check date is empty");

        return holidayService.check(format.parse(day));
    }
}
